<?php


if (empty($_FILES['avatar'])){
    exit('请先上传文件');
}

//接受客户端文件
$avatar = $_FILES['avatar'];

if ($avatar['error'] !== UPLOAD_ERR_OK){
    exit('上传失败');
}

//获取文件扩展名,便验证
$ext = pathinfo($avatar['name'],PATHINFO_EXTENSION);

//保存路径
$target = '../../static/uploads/img-'.uniqid().'.'.$ext;
// ../../static/uploads/img-hierthitr.jpg

//移动文件,保存数据
if (!move_uploaded_file($avatar['tmp_name'],$target)){
    exit('移动失败');
}


echo substr($target,5); //







